package com.cn.lf.wx.dacs.bussiness.author.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.cn.lf.wx.dacs.bussiness.author.bean.ReturnEntity;
import com.cn.lf.wx.dacs.bussiness.author.bean.req.RoleHaveMenus;
import com.cn.lf.wx.dacs.bussiness.author.serviceImpl.AuthRoleServiceImpl;

@RestController
public class AuthRoleApi {

	@Autowired
    private AuthRoleServiceImpl authRoleService;


    //    获取角色列表
    @GetMapping("/admin/auth/roles")
    public ReturnEntity roles() {
        return authRoleService.roles();
    }

    //    添加角色

   // @PreAuthorize("@permission.login()")
    @PostMapping("/admin/auth/role")
    public ReturnEntity createRole(@RequestBody RoleHaveMenus adminRole) {
        return authRoleService.createRole(adminRole);
    }

    //    修改角色 拥有菜单
       // @PreAuthorize("@permission.login()")
    @PutMapping("/admin/auth/role")
    public ReturnEntity changeRole(@RequestBody RoleHaveMenus roleHaveMenus) {
        return authRoleService.changeRole(roleHaveMenus);
    }

    //    删除角色
    //@PreAuthorize("@permission.login()")
    @DeleteMapping("/admin/auth/role/{id}")
    public ReturnEntity deleteRole(@PathVariable("id") String id) {
        return authRoleService.deleteRole(id);
    }

}
